<template>
  <div class="my_div" @click="$emit('like', dogName)">
    <img
      src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
      alt=""
    />
    <p @click.stop="fn" :style="{ background: bgcolor }">{{ dogName }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      bgcolor: "",
    };
  },
  methods: {
    getRandom() {
      return Math.floor(Math.random() * 256);
    },
    fn() {
      this.bgcolor = `rgb(${this.getRandom()} ,${this.getRandom()},${this.getRandom()})`;
    },
  },
  props: {
    dogName: {
      type: String,
    },
    doImgUrl: {
      type: String,
    },
  },
};
</script>

<style>
.my_div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
  margin-right: 45px;
}

.my_div img {
  width: 100%;
  height: 200px;
}
</style>
